<%@ page import="java.util.List" %>
<%@ page import="com.day240701.entity.Student" %><%--
  Created by IntelliJ IDEA.
  User: 王文尧
  Date: 2024/7/2
  Time: 11:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <script type="text/javascript">

        <%
            String msg = (String) session.getAttribute("msg");
            session.removeAttribute("msg");
            if (msg != null) {
        %>
        alert("<%=msg%>");
        <%
            }
        %>
        function deleteConfirm(sNo) {
            var flag = confirm("您确认要删除" + sNo + "吗？");
            if (flag) {
                /*document.getElementById("deleteStudent").setAttribute("href", "student?op=deleteStudentBySNo&sNo=" + sNo);*/
                window.location.href = "manage?op=deleteStudentBySNo&sNo=" + sNo;
            }
        }
    </script>
    <%
        /*// 登录状态判断
        Integer sNo = (Integer) session.getAttribute("sNo");
        if (sNo == null) {
            session.setAttribute("msg", "请登录后再访问！");
            response.sendRedirect("login.jsp");
        }*/

        // 通过属性名 sList 获得 request 打包来的 数据
        // 原来为 Object 类型，记得强转 为对应类型才能使用
        List<Student> sList = (List<Student>) request.getAttribute("sList");
    %>

    <table border="1">
        <tr>
            <th>学号</th><th>姓名</th><th>密码</th><th>性别</th><th>年龄</th><th>操作</th>
        </tr>
    <%
        for (Student stu : sList) {
    %>
        <tr>
            <td><%=stu.getSNo()%></td>
            <td><%=stu.getSName()%></td>
            <td><%=stu.getPassword()%></td>
            <td><%=stu.getSex()%></td>
            <td><%=stu.getAge()%></td>
            <%--href="student?op=deleteStudentBySNo&sNo=<%=stu.getSNo()%>"--%>
            <td><a href="manage?op=queryStudentInfo&sNo=<%=stu.getSNo()%>" style="cursor: pointer;color: blue">修改</a>|<a id="deleteStudent" onclick="deleteConfirm('<%=stu.getSNo()%>')" style="cursor: pointer;color: blue">删除</a></td>

        </tr>
    <%
        }
    %>
    </table>
</body>
</html>
